﻿using Common.Encrypt;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Text;
namespace Common.Web
{
    /// <summary>
    /// 敏感数据
    /// </summary>
    public static class SensitiveDataApplicationBuilderExtensions
    {
        /// <summary>
        /// 使用脱敏数据处理
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="config">敏感数据配置</param>
        /// <returns></returns>
        public static IApplicationBuilder UseSensitiveData(this IApplicationBuilder builder, SensitiveDataConfig config)
        {
            if (config == null)
            {
                config = new SensitiveDataConfig();
            }
            SensitiveDataController.Provider = new SensitiveDataProvider(config);
            return builder;
        }
    }

    /// <summary>
    /// API的数据脱敏
    /// </summary>
    public class SensitiveDataController
    {
        /// <summary>
        /// 脱敏数据提供者
        /// </summary>
        public static SensitiveDataProvider Provider { get; set; }
    }


}
